package com.wg.entity;
/***********************************************************************
 * Module:  WGInfo.java
 * Author:  13229
 * Purpose: Defines the Class WGInfo
 ***********************************************************************/

import com.wg.model.ObjectZip;
import lombok.Data;


import java.util.*;
@Data
public class WGInfo implements ObjectZip {
   public int id;
   public String name = "";
   /**
    * 计划表,暂时设置为目录
    */
   public String schedule = "";
   /**
    * 描述
    */
   public String description = "";
   /**
    * 创建者
    */
   public String creator = "";
   /**
    * 保存成员Id
    */
   public ArrayList member = new ArrayList();
   /**
    * 保存关注者Id
    */
   public ArrayList focusUser = new ArrayList();

   @Override
   public String serialize() {
      return id + ":" + name + ":" + schedule + ":" + description + ":"
              + creator + ":" + JoinArrayList(member, ",") + ":" + JoinArrayList(focusUser, ",");
   }

   @Override
   public void deserialize(String info) {
      ArrayList list = new ArrayList(Arrays.asList(info.split(":")));
      id = Integer.parseInt((String)list.get(0));
      name = (String)list.get(1);
      schedule = (String)list.get(2);
      description = (String)list.get(3);
      creator = (String)list.get(4);
      member = new ArrayList(Arrays.asList(((String)list.get(5)).split(",")));
      focusUser = new ArrayList(Arrays.asList(((String)list.get(6)).split(",")));
   }

   String JoinArrayList(ArrayList list, String joinStr){
      String ret = "";

      for (int i = 0; i < list.size(); i++) {
         if (i != 0){
            ret += joinStr;
         }
         ret += list.get(i);
      }

      return ret;
   }
}